<template>
	<!-- :iconLeft="true" 显示左返回 || :isBack="true" @goBack="goBack" ：自定义返回； 不写默认返回上一层 -->
	<view>
		<view class="navBar ff-flex" :style="navStyle">
			<view class="content ff-text-center">
				<view class="iconLeft w-align-items-one" v-if="iconLeft" @click="backClick">
					<image src="https://fire-system.oss-cn-beijing.aliyuncs.com/web/new-fire-iot/backIcon.png" mode="">
					</image>
					<!-- <view><u-icon name="arrow-left" class="arrow-left" color="#ffffff" size="40"></u-icon></view> -->
					<!-- <view class="w-font-15 w-font-weight-500">返回</view> -->
				</view>
				{{ props.title }}
			</view>
		</view>
		<view :style="tabberStyle"></view>
	</view>
</template>

<script setup>
	import { computed, getCurrentInstance } from 'vue';
	const { proxy } = getCurrentInstance();
	let props = defineProps(['title', 'iconLeft', 'isBack']);
	const navStyle = computed(() => {
		const lineHeight = proxy.customBar - proxy.statusBar;
		return `height:${proxy.customBar}px;padding-top:${proxy.statusBar}px;line-height:${lineHeight}px`;
	});
	const tabberStyle = computed(() => {
		return `height:${proxy.customBar}px;`;
	});
	// 点击返回按钮
	const emit = defineEmits(['goBack']); // 不能在局部使用, defineEmits如果放在局部。不在全局。则报错
	let backClick = () => {
		if (props.isBack) {
			emit('goBack');
			return;
		}
		proxy.$pageJump.navigateBack();
	};
</script>

<style lang="scss" scoped>
	.navBar {
		position: fixed;
		left: 0;
		top: 0;
		width: 100%;
		z-index: 9;
		opacity: 1;
		background-color: #fff;
		color: #ffffff;

		.content {
			flex: 1;
			font-size: 32rpx;
			font-weight: 500;
			display: flex;
			align-items: center;
			justify-content: center;
			color: #000;

			.iconLeft {
				position: absolute;
				left: 0;
				padding: 10rpx 30rpx;
				font-size: 28rpx;
				font-weight: 400;
				display: flex;
				align-items: center;
				justify-content: center;

				image {
					width: 35rpx;
					height: 35rpx;
				}

				:deep(.arrow-left) {
					font-weight: 300 !important;
					margin-right: 6rpx;
				}
			}
		}
	}
</style>